package com.learning.java.optimize.design.pattern.strategy;

import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * ClassName: FeeCalculationService
 * Description: 收银服务
 * Date: 2020/3/22 17:11 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Service
public class FeeCalculationService {

    private static final String VIP = "VIP";
    private static final double VIP_DISCOUNT = 0.95;
    private static final String SVIP = "SVIP";
    private static final double SVIP_DISCOUNT = 0.9;

    /**
     * 收银方法
     *
     * @param type 会员类型
     * @param fee  费用
     * @return
     */
    public double calculation(String type, double fee) {
        if (Objects.equals(VIP, type)) {
            return fee * VIP_DISCOUNT;
        } else if (Objects.equals(SVIP, type)) {
            return fee * SVIP_DISCOUNT;
        }
        return fee;
    }
}
